﻿using System.Linq;
using static CyberU;
using static CyberU.UI;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;

public class DeleteNode : NodeOperation
{
    public void Awake()
    {
        base.Awake();
        clicker.AddLeft(() =>
        {
            foreach (var edgeData in node.graph.data.edgeDatas.ToList())
            {
                if (edgeData.edge.from == node||edgeData.edge.to == node)
                {
                    node.graph.DeleteEdge(edgeData:edgeData);
                }
            }

            node.graph.data.nodeDatas.Remove(node.data);
            DestroyGameObject(node);
            // Delog(1);
        });
        
    }
}